#include "ReadWriteMemoryR3.h"
#include "commonR3.h"



CReadWriteMemoryR3::CReadWriteMemoryR3()
{
	this->Init();

}

CReadWriteMemoryR3::~CReadWriteMemoryR3()
{

}

bool CReadWriteMemoryR3::Read(HANDLE pid,ULONG64 srcAddr, PULONG64 dstAddr,ULONG32 bufLen)
{
	
	char buf[0xe0] = {0};
	stCommonDate * date = (stCommonDate*)buf;

	date->id = 0x123456;
	date->cmd = READMEMORY;
	date->pid = (ULONG64)pid;
	date->srcAddr = srcAddr;
	date->dstAddr = (ULONG64)dstAddr;
	date->size = bufLen;
	date->reStatus = -1;

	this->SendBuf(date,0xe0);

	return date->reStatus == 0;
}

bool CReadWriteMemoryR3::Write(HANDLE pid, ULONG64 writeAddr, PULONG64 writeValueAddr, ULONG32 bufLen)
{
	char buf[0xe0] = { 0 };
	stCommonDate* date = (stCommonDate*)buf;

	date->id = 0x123456;
	date->cmd = WRITEMEMORY;
	date->pid = (ULONG64)pid;
	date->srcAddr = writeAddr;
	date->dstAddr = (ULONG64)writeValueAddr;
	date->size = bufLen;
	date->reStatus = -1;

	this->SendBuf(date, 0xe0);

	return date->reStatus == 0;
}

bool CReadWriteMemoryR3::GetModuleBase(HANDLE pid, char* moduleName, PULONG64 mouleBase)
{
	char buf[0xe0] = { 0 };
	stCommonDate* date = (stCommonDate*)buf;

	date->id = 0x123456;
	date->cmd = GETMODULEBASE;
	date->pid = (ULONG64)pid;
	date->srcAddr =(ULONG64) moduleName;
	date->dstAddr = (ULONG64)mouleBase;
	date->size = 0;
	date->reStatus = -1;

	this->SendBuf(date, 0xe0);

	return date->reStatus == 0;
}

bool CReadWriteMemoryR3::RemoteCall(HANDLE pid, char* shellCode, DWORD bufLen)
{
	char buf[0xe0] = { 0 };
	stCommonDate* date = (stCommonDate*)buf;

	date->id = 0x123456;
	date->cmd = REMOTECALL;
	date->pid = (ULONG64)pid;
	date->srcAddr = (ULONG64)shellCode;
	date->dstAddr =0;
	date->size = bufLen;
	date->reStatus = -1;

	this->SendBuf(date, 0xe0);

	return date->reStatus == 0;
}

void CReadWriteMemoryR3::SendDate(PVOID buf, DWORD bufLen)
{
}



